package cn.itcast.bos.base.action;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;

import cn.itcast.bos.base.service.StandardService;
import cn.itcast.bos.domain.base.Standard;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;


@ParentPackage("json-default")
@Namespace("/")
@Controller
@Scope("prototype")
public class StandardAction extends BaseAction<Standard>{
	@Autowired
	private StandardService standardService;
	@Action(value="standard",results={@Result(name="success",location="/pages/base/standard.html",type="redirect")})
	public String addStandard(){
		System.out.println(t.getName());
		standardService.addStandard(t);
		return SUCCESS;
	}
	
	@Action(value="showStandard",results={@Result(name="success",type="json")})
	public String showStandard(){
		Pageable pageable=new PageRequest(page-1, rows);
		Page<Standard> pagedata = standardService.showStandard(pageable);
		putIntoValueStack(pagedata);
		return SUCCESS;
	}
	
	@Action(value="getAllstandard",results={@Result(type="json",name="success")})
	public String getAllstandard(){
		List<Standard> list = standardService.getAllstandard();
		ActionContext.getContext().getValueStack().push(list);
		return SUCCESS;
	}
}
